'use strict';
module.exports = app => {
  const { STRING, INTEGER } = app.Sequelize;
    const Model = app.model.define(
      'server',
      {
          id: {type: INTEGER, primaryKey: true, autoIncrement: true},
          name: STRING(255),
          area_id: INTEGER(11),
          sort: STRING(255),
          status: INTEGER(11),
      },
      {
          tableName: 'server',
          timestamps: true, // 启用时间戳(createdAt, updatedAt)
          updatedAt: 'updated_time', // 不想要 updatedAt
          createdAt: 'create_time', // 想要  createdAt 但是希望名称叫做 created_at
      }
    );
    Model.associate = function() {
        // area
        app.model.Server.belongsTo(app.model.Area, { foreignKey: 'area_id', targetKey: 'id', as: 'area' });
    }
    return Model;
};
